﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designer.Shell
{
    public class CZEnvironment
    {
        /// <summary>
        /// 承载应用的站点地址
        /// </summary>
        public static string HostUrl { get; set; }
        public static string UserIdentity { get; set; }
        public static string UserAccount { get; set; }
        public static string UserPassword { get; set; }
        public static string Solution { get; set; }

        public static string GetPartLibBaseAddress()
        {
            if (string.IsNullOrEmpty(HostUrl))
            {
                return AppDomain.CurrentDomain.BaseDirectory;
            }
            return CZEnvironment.HostUrl;
        }

        public static string GetHostConfigFilePath()
        {
            if (string.IsNullOrEmpty(HostUrl))
            {
                return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Config\\host.xml");
            }
            return string.Format("{0}{1}", HostUrl, "Config/Host.xml");
        }

        public static string GetPartLibConfigFilePath()
        {
            if (string.IsNullOrEmpty(HostUrl))
            {
                return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Config\\partlibs.xml");
            }
            return string.Format("{0}{1}", HostUrl, "Config/partlibs.xml");
        }

        /// <summary>
        /// 获取日志目录
        /// </summary>
        /// <returns></returns>
        public static string GetLogDirectory()
        {
            return string.Format("C:\\Coolzon\\Designer\\V{0}\\Logs\\", Version4);
        }

        private static Version _version;
        /// <summary>
        /// 获得主程序的版本号
        /// </summary>
        public static Version Version
        {
            get
            {
                if (_version == null)
                {
                    _version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
                }
                return _version;
            }
        }
        /// <summary>
        /// 版本信息-.-.-.-
        /// </summary>
        public static string Version4
        {
            get
            {
                return Version.ToString(4);
            }
        }
    }
}
